package com.grape.demo20220803.jms;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

/**
 * @Author pan_jin
 * @Description: $
 * @Date: 2022/8/12 10:29
 * @Version: 1.0.0
 * @Slogan: 梦想还是要有的万一实现了呢
 */
@Component
public class MessagingService {

    /** @noinspection SpringJavaInjectionPointsAutowiringInspection*/
    @Autowired
    JmsTemplate jmsTemplate;
    public void sendMailMessage(){
        String text="hello world";
        jmsTemplate.send("jms/query/mail", new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage(text);
            }
        });
    }
}
